# coding:utf-8
'''
Created on 2015-1-5

@author: scemoon
@summary: 初始化lpts环境，包括:
    1)添加lpts工程目录到sys.path
    2)设定DJANGO_SETTINGS_MODULE="web.settings"

'''

__all__ = ["inital"]

import os, sys

LPTS_PROJECT_DIR=os.path.join(os.path.dirname(os.path.dirname(__file__)), "web")
def  init(project_dir=LPTS_PROJECT_DIR, settings_file="web.settings"):
    '''判断project_dir(lpts工程目录)是否存在于sys.path中，如果不存在则添加到sys.path中，同时设定
    project_dir的运行环境变量web.settings'''
    if  project_dir not in sys.path:
        sys.path.append(project_dir)
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_file)
